package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class SupplierController {
    @Autowired
    private SupplierService supplierService;
   //查看所有供货商
    @PostMapping("/supplier/list")
    public Map<String,Object> supplierList(Integer page, Integer rows, String supplierName){
       return supplierService.supplierList(page,rows,supplierName);
    }
    // 实现供货商的 添加的 更新
    @PostMapping("/supplier/save")
    public ServiceVO saveOrUpdate (Long supplierId, Supplier supplier){
      supplierService.saveOrUpdate(supplierId,supplier);
      return new ServiceVO(100,"请求成功",null);
    }
    // 实现 供货商的 删除
    @PostMapping("/supplier/delete")
    public ServiceVO  delete( String ids ){
        supplierService.delete(ids);
        return new ServiceVO(100,"请求成功",null);
    }
}
